#include "Eventfd.hpp"

#include <unistd.h>

#include <iostream>

#include <thread>
using std::cout;
using std::endl;

struct Mytask{
    void process(){
        srand(time(nullptr));
        int num = rand() % 100;
        printf("make a number: %d \n", num);
    }
};

int main()
{
    wd::Eventfd event(std::bind(&Mytask::process,Mytask()));
    //EVentfd的start函数是子线程的入口函数
    std::thread th(&wd::Eventfd::start,&event);

    int cnt = 10;
    while(cnt--){
        event.wakeup();
        sleep(1);
    }

    sleep(6);
    event.stop();
    th.join();

    return 0;
}

